package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TGongz;
import com.ruoyi.system.service.ITGongzService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 工装 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-26
 */
@Controller
@RequestMapping("/system/tGongz")
public class TGongzController extends BaseController
{
    private String prefix = "system/tGongz";
	
	@Autowired
	private ITGongzService tGongzService;
	
	@RequiresPermissions("system:tGongz:view")
	@GetMapping()
	public String tGongz()
	{
	    return prefix + "/tGongz";
	}
	
	/**
	 * 查询工装列表
	 */
	@RequiresPermissions("system:tGongz:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TGongz tGongz)
	{
		startPage();
        List<TGongz> list = tGongzService.selectTGongzList(tGongz);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出工装列表
	 */
	@RequiresPermissions("system:tGongz:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGongz tGongz)
    {
    	List<TGongz> list = tGongzService.selectTGongzList(tGongz);
        ExcelUtil<TGongz> util = new ExcelUtil<TGongz>(TGongz.class);
        return util.exportExcel(list, "tGongz");
    }
	
	/**
	 * 新增工装
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存工装
	 */
	@RequiresPermissions("system:tGongz:add")
	@Log(title = "工装", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TGongz tGongz)
	{		
		return toAjax(tGongzService.insertTGongz(tGongz));
	}

	/**
	 * 修改工装
	 */
	@GetMapping("/edit/{gzId}")
	public String edit(@PathVariable("gzId") String gzId, ModelMap mmap)
	{
		TGongz tGongz = tGongzService.selectTGongzById(gzId);
		mmap.put("tGongz", tGongz);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存工装
	 */
	@RequiresPermissions("system:tGongz:edit")
	@Log(title = "工装", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TGongz tGongz)
	{		
		return toAjax(tGongzService.updateTGongz(tGongz));
	}
	
	/**
	 * 删除工装
	 */
	@RequiresPermissions("system:tGongz:remove")
	@Log(title = "工装", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(tGongzService.deleteTGongzByIds(ids));
	}
	
}
